//
//  NSObject+ZJUIStyle.m
//  ZiJinLian
//
//  Created by lzy on 2017/3/18.
//  Copyright © 2017年 lzy. All rights reserved.
//

#import "NSObject+ZJUIStyle.h"

@implementation NSObject (ZJUIStyle)

@end

@implementation UIButton (ZJUIStyle)


+(instancetype)creatBtn{
    UIButton *btn=[self buttonWithType:UIButtonTypeCustom];
    btn.frame=CGRectZero;
    return btn;
}


//按钮 图片 左 ，按钮 右   间隔10
-(void)ZJButtonStyleWithBgImg:(NSString *)imgName withTitle:(NSString *)title
{
    self.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
    [self setTitle:title forState:UIControlStateNormal];
    //上左下右
    self.backgroundColor=HJ_Color(203, 8, 20);
    [self setImage:[UIImage imageNamed:imgName] forState:0];
    [self setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    self.titleLabel.font=FontAndStyle14;
    self.imageEdgeInsets=UIEdgeInsetsMake(0, -10, 0, 0);
}

@end

@implementation UITableView (ZJUIStyle)

+ (instancetype)tableView
{
    UITableView *_tableView = [[self alloc] initWithFrame:CGRectZero
                                                    style:UITableViewStylePlain];
    [_tableView setIndicatorStyle:UIScrollViewIndicatorStyleWhite];
    _tableView.scrollEnabled = YES;
    _tableView.userInteractionEnabled = YES;
    //RGB(246, 246, 246);
    _tableView.backgroundColor =RGB(246, 246, 246);
    [_tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
    
    return _tableView;
}

+ (instancetype)groupTableView
{
    UITableView *_tableView = [[self alloc] initWithFrame:CGRectZero
                                                    style:UITableViewStyleGrouped];
    
    [_tableView setIndicatorStyle:UIScrollViewIndicatorStyleWhite];
    _tableView.scrollEnabled = YES;
    _tableView.userInteractionEnabled = YES;
    _tableView.backgroundColor = [UIColor clearColor];
    _tableView.backgroundView = nil;
    _tableView.sectionHeaderHeight = 0.f;
    _tableView.sectionFooterHeight = 0.f;
    [_tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
    return _tableView;
}


//对象方法
- (void)scrollToBottom
{
    NSInteger sectionCount = [self.dataSource numberOfSectionsInTableView:self];
    NSInteger lastSectionRowCount = [self.dataSource tableView:self numberOfRowsInSection:sectionCount-1];
    
    NSIndexPath *indexPath = [NSIndexPath indexPathForRow:lastSectionRowCount-1 inSection:sectionCount-1];
    [self scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewRowAnimationTop animated:YES];
}


@end




